package com.zy.teacher.controller;

import com.zy.commont.result.Result;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@CrossOrigin //跨域请求
public class UserController {

    @PostMapping("/login")
    public Result login(){
        return Result.ok().data("token","admin");
    }
    @GetMapping("info")
    public Result info(){
        //"data":
        // {"roles":["admin"],
        // "name":"admin",
        // "avatar":"https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"}
        return Result.ok()
                .data("roles","[\"admin\"]")
                .data("name","admin")
                .data("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
    }

    //http://localhost:9000/user/logout
    @PostMapping("/logout")
    public Result logout(){
        return Result.ok().data("token","admin");
    }
}
